﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2006
' by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
 */

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace Triax.Modules.Department
{
    /// -----------------------------------------------------------------------------
    ///<summary>
    /// The Info class for the Department
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// </history>
    /// -----------------------------------------------------------------------------
    public class Triax_KetHopXuLy : DoiTuong
    {

        //#region Private Members
        //private int _ModuleId;
        //private int _id;
        //private string _code;
        //private string _title;
        //private DateTime _Thoigian;
        //private int _ParentId;
        //private string _Description;
        //private double _temp_double1;
        //private double _temp_double2;
        //private string _temp_string1;
        //private string _temp_string2;
        //private string _temp_string3;
        //private int _temp_int1;
        //private int _temp_int2;
        //private int _temp_int3;
        //private int _CreatedByUser;
        //private DateTime _CreatedDate;
        //private int _UpdatedByUser;
        //private DateTime _UpdatedDate;





        //#endregion

        //public int ModuleId
        //{
        //    get
        //    {
        //        return _ModuleId;
        //    }
        //    set
        //    {
        //        _ModuleId = value;
        //    }
        //}
        //#region Constructors

        //// initialization
        //public Triax_KetHopXuLy()
        //{
        //}

        //#endregion

        //#region Public Properties

        ///// <summary>
        ///// Gets and sets the Module Id
        ///// </summary>
        //public int id { get { return _id; } set { _id = value; } }
        //public string code { get { return _code; } set { _code = value; } }
        //public string title { get { return _title; } set { _title = value; } }
        //public int ParentId { get { return _ParentId; } set { _ParentId = value; } }
        //public string Description { get { return _Description; } set { _Description = value; } }
        //public double temp_double1 { get { return _temp_double1; } set { _temp_double1 = value; } }
        //public double temp_double2 { get { return _temp_double2; } set { _temp_double2 = value; } }
        //public string temp_string1 { get { return _temp_string1; } set { _temp_string1 = value; } }
        //public string temp_string2 { get { return _temp_string2; } set { _temp_string2 = value; } }
        //public string temp_string3 { get { return _temp_string3; } set { _temp_string3 = value; } }
        //public int temp_int1 { get { return _temp_int1; } set { _temp_int1 = value; } }
        //public int temp_int2 { get { return _temp_int2; } set { _temp_int2 = value; } }
        //public int temp_int3 { get { return _temp_int3; } set { _temp_int3 = value; } }
        //public int CreatedByUser { get { return _CreatedByUser; } set { _CreatedByUser = value; } }
        //public DateTime CreatedDate { get { return _CreatedDate; } set { _CreatedDate = value; } }
        //public int UpdatedByUser { get { return _UpdatedByUser; } set { _UpdatedByUser = value; } }
        //public DateTime UpdatedDate { get { return _UpdatedDate; } set { _UpdatedDate = value; } }
        //public DateTime Thoigian { get { return _Thoigian; } set { _Thoigian = value; } }




        //#endregion

        #region int ModuleId property
        public int ModuleId
        {
            get
            {
                if (_DataRow["ModuleId"] is int) return (int)_DataRow["ModuleId"];
                return 0;
            }
            set
            {
                _DataRow["ModuleId"] = value;
            }
        }
        #endregion

        #region string code property
        public string code
        {
            get
            {
                if (_DataRow["code"] is string) return (string)_DataRow["code"];
                return "";
            }
            set
            {
                _DataRow["code"] = value;
            }
        }
        #endregion

        #region string title property
        public string title
        {
            get
            {
                if (_DataRow["title"] is string) return (string)_DataRow["title"];
                return "";
            }
            set
            {
                _DataRow["title"] = value;
            }
        }
        #endregion

        #region DateTime? Thoigian property
        public DateTime? Thoigian
        {
            get
            {
                if (_DataRow["Thoigian"] is DateTime?) return (DateTime?)_DataRow["Thoigian"];
                return null;
            }
            set
            {
                _DataRow["Thoigian"] = value;
            }
        }
        #endregion

        #region int ParentId property
        public int ParentId
        {
            get
            {
                if (_DataRow["ParentId"] is int) return (int)_DataRow["ParentId"];
                return 0;
            }
            set
            {
                _DataRow["ParentId"] = value;
            }
        }
        #endregion

        #region string Description property
        public string Description
        {
            get
            {
                if (_DataRow["Description"] is string) return (string)_DataRow["Description"];
                return "";
            }
            set
            {
                _DataRow["Description"] = value;
            }
        }
        #endregion

        #region decimal temp_double1 property
        public decimal temp_double1
        {
            get
            {
                if (_DataRow["temp_double1"] is decimal) return (decimal)_DataRow["temp_double1"];
                return 0;
            }
            set
            {
                _DataRow["temp_double1"] = value;
            }
        }
        #endregion

        #region decimal temp_double2 property
        public decimal temp_double2
        {
            get
            {
                if (_DataRow["temp_double2"] is decimal) return (decimal)_DataRow["temp_double2"];
                return 0;
            }
            set
            {
                _DataRow["temp_double2"] = value;
            }
        }
        #endregion

        #region string temp_string1 property
        public string temp_string1
        {
            get
            {
                if (_DataRow["temp_string1"] is string) return (string)_DataRow["temp_string1"];
                return "";
            }
            set
            {
                _DataRow["temp_string1"] = value;
            }
        }
        #endregion

        #region string temp_string2 property
        public string temp_string2
        {
            get
            {
                if (_DataRow["temp_string2"] is string) return (string)_DataRow["temp_string2"];
                return "";
            }
            set
            {
                _DataRow["temp_string2"] = value;
            }
        }
        #endregion

        #region string temp_string3 property
        public string temp_string3
        {
            get
            {
                if (_DataRow["temp_string3"] is string) return (string)_DataRow["temp_string3"];
                return "";
            }
            set
            {
                _DataRow["temp_string3"] = value;
            }
        }
        #endregion

        #region int temp_int1 property
        public int temp_int1
        {
            get
            {
                if (_DataRow["temp_int1"] is int) return (int)_DataRow["temp_int1"];
                return 0;
            }
            set
            {
                _DataRow["temp_int1"] = value;
            }
        }
        #endregion

        #region int temp_int2 property
        public int temp_int2
        {
            get
            {
                if (_DataRow["temp_int2"] is int) return (int)_DataRow["temp_int2"];
                return 0;
            }
            set
            {
                _DataRow["temp_int2"] = value;
            }
        }
        #endregion

        #region int temp_int3 property
        public int temp_int3
        {
            get
            {
                if (_DataRow["temp_int3"] is int) return (int)_DataRow["temp_int3"];
                return 0;
            }
            set
            {
                _DataRow["temp_int3"] = value;
            }
        }
        #endregion

        #region int CreatedByUser property
        public int CreatedByUser
        {
            get
            {
                if (_DataRow["CreatedByUser"] is int) return (int)_DataRow["CreatedByUser"];
                return 0;
            }
            set
            {
                _DataRow["CreatedByUser"] = value;
            }
        }
        #endregion

        #region DateTime? CreatedDate property
        public DateTime? CreatedDate
        {
            get
            {
                if (_DataRow["CreatedDate"] is DateTime?) return (DateTime?)_DataRow["CreatedDate"];
                return null;
            }
            set
            {
                _DataRow["CreatedDate"] = value;
            }
        }
        #endregion

        #region int UpdatedByUser property
        public int UpdatedByUser
        {
            get
            {
                if (_DataRow["UpdatedByUser"] is int) return (int)_DataRow["UpdatedByUser"];
                return 0;
            }
            set
            {
                _DataRow["UpdatedByUser"] = value;
            }
        }
        #endregion

        #region DateTime? UpdatedDate property
        public DateTime? UpdatedDate
        {
            get
            {
                if (_DataRow["UpdatedDate"] is DateTime?) return (DateTime?)_DataRow["UpdatedDate"];
                return null;
            }
            set
            {
                _DataRow["UpdatedDate"] = value;
            }
        }
        #endregion

        public Triax_KetHopXuLy(DataRow dataRow)
            : base(dataRow)
        {
        }
    }

    public class DanhMucTriax_KetHopXuLy : DanhMucDoiTuong, IEnumerable
    {
        #region Instance property: Singleton Design pattern
        private static DanhMucTriax_KetHopXuLy _Instance;
        public static DanhMucTriax_KetHopXuLy Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new DanhMucTriax_KetHopXuLy();
                    _Instance.DataView = _Instance.DataTable.DefaultView;
                }

                return _Instance;
            }
        }
        #endregion

        #region override TableName property
        public override string TableName
        {
            get
            {
                return "Triax_KetHopXuLy";
            }
        }
        #endregion

        #region Methods required by IEnumerable (use for foreach)
        public IEnumerator GetEnumerator()
        {
            return new TokenEnumerator(this);
        }

        private class TokenEnumerator : IEnumerator
        {
            private int _Position = -1;
            DanhMucDoiTuong _Dstk;

            public TokenEnumerator(DanhMucDoiTuong dstk)
            {
                _Dstk = dstk;
            }

            // Declare the MoveNext method required by IEnumerator:
            public bool MoveNext()
            {
                if (_Position < _Dstk.DataView.Count - 1)
                {
                    _Position++;
                    return true;
                }
                else
                {
                    return false;
                }
            }

            // Declare the Reset method required by IEnumerator:
            public void Reset()
            {
                _Position = -1;
            }

            // Declare the Current property required by IEnumerator:
            public object Current
            {
                get
                {
                    return new Triax_KetHopXuLy((_Dstk.DataView[_Position].Row));
                }
            }
        }
        #endregion

        public Triax_KetHopXuLy this[int index]
        {
            get
            {
                if (0 <= index && index <= this.Count)
                {
                    return new Triax_KetHopXuLy(DataTable.Rows[index]);
                }
                else
                {
                    return null;
                }
            }
        }

        public Triax_KetHopXuLy NewDoiTuong()
        {
            try
            {
                return new Triax_KetHopXuLy(Instance.DataTable.NewRow());
            }
            catch (Exception ex)
            {
                if (ex is Exception) throw ex;
                else
                {
                    throw new Exception(ex.Message);
                }
            }
        }

        //public Triax_KetHopXuLy GetByID(int objID)
        //{
        //    try
        //    {
        //        //return GetByProperty("ID", objID);
        //    }
        //    catch (Exception ex)
        //    {
        //        if (ex is Exception) throw ex;
        //        else
        //        {
        //            throw new Exception(ex.Message);
        //        }
        //    }
        //}

        //public override List<Triax_KetHopXuLy> SearchByCon(string condition)
        //{
        //    SqlConnection con = new SqlConnection(CommonLib.ConnectString);
        //    List<Triax_KetHopXuLy> lst = new List<Triax_KetHopXuLy>();
        //    try
        //    {
        //        con.Open();
        //        SqlCommand cmd = con.CreateCommand();
        //        cmd.CommandText = string.Format("SELECT * FROM [{0}] WHERE 1=1 {1}",
        //                                            TableName,
        //                                            condition);

        //        DataTable dt = new DataTable();
        //        SqlDataAdapter da = new SqlDataAdapter();
        //        da.SelectCommand = cmd;
        //        da.Fill(dt);

        //     //   List<Triax_KetHopXuLy> listName = dt.ToList<Triax_KetHopXuLy>();
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }
        //    finally
        //    {
        //        con.Close();
        //    }
        //    return lst;
        //}
    }
}
